//
//  ViewController.m
//  Demo
//
//  Created by 微光星芒 on 2017/11/17.
//  Copyright © 2017年 微光星芒. All rights reserved.
//

#import "ViewController.h"
#import "AddressController.h"
#import "ChildController.h"

#import "CustomBtn.h"
@interface ViewController ()

@property (nonatomic,strong) CustomBtn *btn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.view.backgroundColor = [UIColor whiteColor];

    /*
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(0, 0, 100, 100);
    btn.center = self.view.center;
    btn.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:btn];
*/
    
    
    
//    [btn addTarget:self action:@selector(nextBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
    _btn = [CustomBtn customInit];
    _btn.frame = CGRectMake(0, 0, 100, 100);
    _btn.center = self.view.center;
    [self.view addSubview:_btn];
    
    self.view.backgroundColor = [UIColor orangeColor];
    
    UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] init];
    backBtn.title = @"返回";
    backBtn.tintColor = [UIColor blackColor];
    self.navigationItem.backBarButtonItem = backBtn;
    
    self.navigationController.navigationBar.hidden = YES;
    
    ChildController *controller = [[ChildController alloc]init];
    controller.view.frame = CGRectMake(0, 20, 100, 100);
    controller.view.backgroundColor = [UIColor redColor];
    [self addChildViewController:controller];
    [self.view addSubview:controller.view];
}

- (void)nextBtnAction:(UIButton *)sender{
    AddressController *controller = [[AddressController alloc]init];
    [self.navigationController pushViewController:controller animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
